package com.hdoit.kylin.logical.relative.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;
import com.tennetcn.common.dao.base.IFinderExpression;
import com.tennetcn.common.dao.base.impl.SuperDao;
import com.tennetcn.common.utils.FinderExpressionFactory;
import com.hdoit.kylin.logical.relative.dao.IProjectUserDao;
import com.hdoit.kylin.logical.relative.model.ProjectUser;


/**
* @author luozhicheng
* @email
* @createtime 2017年07月18日 19:21:50
* @comment
*/
@Component
public class ProjectUserDaoImpl extends SuperDao<ProjectUser> implements IProjectUserDao{

	
	@Override
	public List<String> queryList(String loginId){
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("projectId")
						.from(ProjectUser.class)
						.andWhere("employeeId=#{loginId}")
						.setParam("loginId",loginId);
	
		
		return queryList(finderExpression,String.class);
	}
	
	@Override
	public boolean deleteProjectUserByProjectId(String projectId) {
		IFinderExpression finder=FinderExpressionFactory.createExpression();
		finder.delete()
			  .from(ProjectUser.class)
			  .andWhere("projectId=#{projectId}")
			  .setParam("projectId", projectId);
		return delete(finder)>=0;
	}

	public List<String> queryListByProjectId(String projectId){
		IFinderExpression finder=FinderExpressionFactory.createExpression();
		finder.select("employeeId")
			  .from(ProjectUser.class)
			  .andWhere("projectId=#{projectId}")
			  .setParam("projectId", projectId);
		
		return queryList(finder, String.class);
	}



}
